package com.zhoujian.Prototype.DeepCopy;

import lombok.Data;

import java.io.Serializable;

@Data
class Product implements Cloneable, Serializable {
    private String name;
    private double price;
    private int stock;

    //构造函数
    public Product() {
        this.name = name;
        this.price = price;
        this.stock = stock;
    }


    //getter和setter方法
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public int getStock() {
        return stock;
    }

    public void setStock(int stock) {
        this.stock = stock;
    }

    @Override
    public Object clone(){
        try{
            return (Product) super.clone();
        }catch (CloneNotSupportedException e){
            e.printStackTrace();
            return null;
        }
    }
}
